﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Collections;
using System.IO;
using System.Windows.Forms;

namespace PokemonRuby
{
    public class Grass : MoveableObject
    {
        public List<Image> lstImg = new List<Image>();
        public int movingStatus = 0;
        public int movingDirection = 0;
        public int x = 0;
        public int y = 0;
        public int z = 0;
        public Hashtable htGrass = new Hashtable();
        protected string appPath = null;

        public Grass()
        {

        }
        public void LoadMinorCharacter()
        {
            this.htGrass.Clear();
            FileInfo fi = new FileInfo(Application.ExecutablePath);
            this.appPath = fi.Directory.FullName;
            string path = Path.Combine(this.appPath, "CharacterImages");
            string[] sar = Directory.GetFiles(path, "*.png");
            for (int i = 0; i < sar.Length; i++)
            {
                string fileName = sar[i];
                fi = new FileInfo(fileName);

                string key = fi.Name;
                key = key.Substring(0, key.Length - 4);
                key = key.ToLower().Trim();

                Image im = Image.FromFile(fileName);
                this.htGrass.Add(int.Parse(key), im);
            }
        }
        public override bool IdleAction(Map map)
        {
            Random rd = new Random();
            int kq = rd.Next(0, 3);
            if (kq == 0)
            {
                this.x = x + 1;
                movingDirection = 1;
            }
            else if (kq == 1)
            {
                this.x = x - 1;
                movingDirection = 0;
            }
            else if (kq == 2)
            {
                this.y = y + 1;
                movingDirection = 3;
            }
            else
            {
                this.y = y - 1;
                movingDirection = 2;
            }
            return true;
        }
    }
}
